using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using Utility;
namespace BUS
{
    public class tbTrangThaiSPBUS
    {
        public static void Insert_TTSP(tbTrangThaiSP ttsp)
        {
            tbTrangThaiSPDAL ttspDAL = new tbTrangThaiSPDAL();
            ttspDAL.Insert(ttsp);
        }
        public static void Update_TTSP(tbTrangThaiSP ttsp)
        {
            tbTrangThaiSPDAL ttspDAL = new tbTrangThaiSPDAL();
            ttspDAL.Update(ttsp);
        }
        public static void Delete_TTSP(int Id)
        {
            tbTrangThaiSPDAL ttspDAL = new tbTrangThaiSPDAL();
            ttspDAL.Delete (Id );
        }
        public static tbTrangThaiSPCollection Get(string Where,
            int PageIndex,
            int PageSize,
            string OrderBy,
            string OrderDirection,
            out int Total)
        {
            tbTrangThaiSPDAL ttspDAL= new tbTrangThaiSPDAL();
            return ttspDAL.Get(Where, PageIndex, PageSize, OrderBy, OrderDirection, out Total);
        }
        public static tbTrangThaiSPCollection GetAll()
        {
            int Total = 0;
            Criteria cri = new Criteria();
            tbTrangThaiSPDAL ttspDAL = new tbTrangThaiSPDAL();
            return ttspDAL.Get(cri.Criter, 0, 0, tbTrangThaiSPColumns.IdTrangThaiSP.ToString(),
                                    OrderDirection.ASC.ToString(), out Total);
        }
        public static tbTrangThaiSP GetById(int Id)
        {
            int Total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbTrangThaiSPColumns.IdTrangThaiSP.ToString(),
                     Condition.EQUAL, Id);
            tbTrangThaiSPDAL ttspDAL=new tbTrangThaiSPDAL ();
            tbTrangThaiSPCollection ttspCollection = ttspDAL.Get(cri.Criter, 0, 0,
                                                    tbTrangThaiSPColumns.IdTrangThaiSP.ToString(),
                                                    OrderDirection.ASC.ToString(), out Total);
            if(ttspCollection .Count >0)
                return ttspCollection [0];
            return null ;
        }
    }
}
